package com.health.controller;

import com.health.constant.ResultCodeConstant;
import com.health.pojo.domain.ConsultationDO;
import com.health.pojo.domain.ConsultationMessageDO;
import com.health.pojo.dto.*;
import com.health.pojo.query.QueryGroup;
import com.health.service.InteractionService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import java.lang.Boolean;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 医患交互管理
 *
 * @author WUYU_MIN
 * @date 2025-04-29 23:51:18
 */
@Tag(name = "医患交互管理")
@RequestMapping("interaction")
@RestController
public class InteractionController {

    @Autowired
    private InteractionService interactionService;

    /**
     * createConsultation
     *
     * @param consultationCreateDTO 创建咨询会话的入参对象
     * @return
     */
    @RequestMapping(value = "/createConsultation", method = RequestMethod.POST)
    @Operation(summary = "createConsultation")
    @ResponseBody
    public RestResult<Boolean> createConsultation(@RequestBody @Validated(CreateGroup.class) ConsultationCreateDTO consultationCreateDTO) {
        Boolean result = interactionService.createConsultation(consultationCreateDTO);
        return new RestResult<>(ResultCodeConstant.CODE_000000, ResultCodeConstant.CODE_000000_MSG, result);
    }

    /**
     * getConsultation
     *
     * @param consultationQueryDTO 查询咨询会话的入参对象
     * @return
     */
    @RequestMapping(value = "/getConsultation", method = RequestMethod.GET)
    @Operation(summary = "getConsultation")
    public RestResult<ConsultationDO> getConsultation(@Validated(QueryGroup.class) ConsultationQueryDTO consultationQueryDTO) {
        ConsultationDO result = interactionService.getConsultation(consultationQueryDTO);
        return new RestResult<>(ResultCodeConstant.CODE_000000, ResultCodeConstant.CODE_000000_MSG, result);
    }

    /**
     * endConsultation
     *
     * @param consultationQueryDTO 咨询会话的入参对象
     * @return
     */
    @RequestMapping(value = "/endConsultation", method = RequestMethod.PUT)
    @Operation(summary = "endConsultation")
    public RestResult<ConsultationDO> endConsultation(@Validated(QueryGroup.class) ConsultationQueryDTO consultationQueryDTO) {
        ConsultationDO result = interactionService.endConsultation(consultationQueryDTO);
        return new RestResult<>(ResultCodeConstant.CODE_000000, ResultCodeConstant.CODE_000000_MSG, result);
    }

    /**
     * getConsultation
     *
     * @param
     * @return
     */
    @RequestMapping(value = "/getConsultationList", method = RequestMethod.POST)
    @Operation(summary = "getConsultation")
    public RestResult<List<ConsultationDO>> getConsultation(@RequestBody @Validated(QueryGroup.class) ComsultationListDTO comsultationListDTO) {
        List<ConsultationDO> result = interactionService.getConsultationList(comsultationListDTO);
        return new RestResult<>(ResultCodeConstant.CODE_000000, ResultCodeConstant.CODE_000000_MSG, result);
    }


    /**
     * sendMessage
     *
     * @param consultationMessageDTO 发送咨询消息的入参对象
     * @return
     */
    @RequestMapping(value = "/sendMessage", method = RequestMethod.POST)
    @Operation(summary = "sendMessage")
    @ResponseBody
    public RestResult<Boolean> sendMessage(@RequestBody @Validated(CreateGroup.class) ConsultationMessageDTO consultationMessageDTO) {
        System.out.println(consultationMessageDTO);
        Boolean result = interactionService.sendMessage(consultationMessageDTO);
        return new RestResult<>(ResultCodeConstant.CODE_000000, ResultCodeConstant.CODE_000000_MSG, result);
    }

    /**
     * receiveMessage
     *
     * @param messageReceiverDTO 接收咨询消息的入参对象
     * @return
     */
    @RequestMapping(value = "/receiveMessage", method = RequestMethod.GET)
    @Operation(summary = "receiveMessage")
    public RestResult<List<ConsultationMessageDO>> receiveMessage(@Validated(QueryGroup.class) MessageReceiverDTO messageReceiverDTO) {
        List<ConsultationMessageDO> result = interactionService.receiveMessage(messageReceiverDTO);
        return new RestResult<>(ResultCodeConstant.CODE_000000, ResultCodeConstant.CODE_000000_MSG, result);
    }
}
